#!/usr/bin/env python3
# -*- coding:utf-8 -*-
#
from common.handleDb import HandleMysql
from common.readconfig import ReadConfig;
import pymysql
import pymysql.cursors

def testConfig():
  config = ReadConfig()
  c = config.get_sec("source-database")
  print(c)
def testMysql():
  db1 = pymysql.connect(host='localhost',
                             user='root',
                             password='Root123456',
                             db='cncwyc',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)
  try:
    with db1.cursor() as cursor:
      # 读取单个记录
      sql = "SELECT * FROM `ecs_ad`"
      cursor.execute(sql)
      result = cursor.fetchall()
      for row in result:
        print(row)
  finally:
      db1.close()

if __name__ == '__main__':
  print('==========test config ================')
  testConfig()
  print('==========test mysql  ================')
  testMysql()

